<!-- 我的正常 -->

<template>
  <div>
    <MajorTitle title="正常上班规则" />

    <FormRadio label="是否允许迟到" bind="allowLate" :dict="DICT.ALLOW" required @change="changeLate" />

    <div v-if="info.allowLate === 1">
      <FormSelect
        label="允许迟到最大时间"
        bind="lateMaxTime"
        :dict="DICT.MINUTE"
        tip="请选择"
        :width="240"
        noClear
        required
      />
      <FormSlot label="分钟" :width="80" word2 />

      <FormSelect
        label="迟到"
        bind="lateAbsenteeismTime"
        :dict="DICT.MINUTE"
        tip="请选择"
        :width="160"
        word2
        noClear
        required
      />
      <FormSlot label="分钟" :width="80" word2 />

      <FormSelect
        label="作旷工"
        bind="lateAbsenteeismNum"
        :dict="DICT.DAY"
        tip="请选择"
        :width="180"
        word3
        noClear
        required
      />
      <FormSlot label="天处理" :width="120" word2 />
    </div>

    <FormRadio label="是否允许早退" bind="allowEarly" :dict="DICT.ALLOW" required @change="changeEarly" />

    <div v-if="info.allowEarly === 1">
      <FormSelect
        label="允许早退最大时间"
        bind="earlyMaxTime"
        :dict="DICT.MINUTE"
        tip="请选择"
        :width="240"
        noClear
        required
      />
      <FormSlot label="分钟" :width="80" word2 />

      <FormSelect
        label="早退"
        bind="earlyAbsenteeismTime"
        :dict="DICT.MINUTE"
        tip="请选择"
        :width="160"
        word2
        noClear
        required
      />
      <FormSlot label="分钟" :width="80" word2 />

      <FormSelect
        label="作旷工"
        bind="earlyAbsenteeismNum"
        :dict="DICT.DAY"
        tip="请选择"
        :width="180"
        word3
        noClear
        required
      />
      <FormSlot label="天处理" :width="120" word2 />
    </div>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyNormal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixScreen()],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换允许迟到
     */
    changeLate() {
      CORE.merge(this.info, {
        lateMaxTime: 0,
        lateAbsenteeismTime: 0,
        lateAbsenteeismNum: 0,
      })
    },

    /**
     * 切换允许早退
     */
    changeEarly() {
      CORE.merge(this.info, {
        earlyMaxTime: 0,
        earlyAbsenteeismTime: 0,
        earlyAbsenteeismNum: 0,
      })
    },
  },
}
</script>
